package com.tjetc.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.tjetc.domian.Communityevent;

public interface CommunityeventMapper {
    int deleteByPrimaryKey(Integer eventid);

    int insert(Communityevent record);

    int insertSelective(Communityevent record);

    Communityevent selectByPrimaryKey(Integer eventid);

    int updateByPrimaryKeySelective(Communityevent record);

    int updateByPrimaryKey(Communityevent record);
    @Select("select * from communityevent")
    List<Communityevent> select();
    @Select("select * from communityevent where EventName=#{eventname} ")
    Communityevent findByName(String eventname);

@Select("select * from communityevent where eventid=#{id}")
    Communityevent findById(int id);

    @Select("select * from communityevent where EventName like concat('%',#{eventName},'%')")
    List<Communityevent> findByEventNameLike(String eventName);

    @Select("select * from communityevent where EventDate = #{eventDate}")
    List<Communityevent> findByEventDate(String eventDate);

    @Select("select * from communityevent where EventDate between #{startDate} and #{endDate}")
    List<Communityevent> findByDateRange(@Param("startDate") String startDate, @Param("endDate") String endDate);

    @Select("select * from communityevent where location like concat('%',#{location},'%')")
    List<Communityevent> findByLocationLike(String location);

    @Update("CREATE TABLE IF NOT EXISTS event_people_${eventId} " +
            "(" +
            "eventid INT PRIMARY KEY AUTO_INCREMENT, " +
            "name VARCHAR(100) " +
            ")")
    int createTable(int eventId);

    int insertevent( @Param("eventId") int eventId, @Param("name") String name);

    boolean findByUserName(@Param("eventId")int eventId,@Param("name")String currentUser);

    int deleteByName(@Param("eventId")int eventId,@Param("name")String currentUser);
}